package com.hmall.api.item;

import com.hmall.api.item.dto.ItemDTO;
import com.hmall.api.item.dto.OrderDetailDTO;
import com.hmall.api.item.fallback.ItemClientFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.Collection;
import java.util.List;

/**
 * 商品服务的Feign客户端接口类
 *
 * @Author mr.wu
 * @Date 2025-8-20 20:53
 */
@FeignClient(value = "item-service", path = "/items", fallbackFactory = ItemClientFallbackFactory.class)
public interface ItemClient {

    /**
     * 根据id批量查询商品
     * @param ids
     * @return
     */
    @GetMapping
    List<ItemDTO> queryItemByIds(@RequestParam("ids") Collection<Long> ids);

    /**
     * 批量扣减库存
     * @param items
     */
    @PutMapping("/stock/deduct")
    void deductStock(@RequestBody List<OrderDetailDTO> items);
}
